<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
        
    <title>java - Load and display all the images from a folder - Stack Overflow</title>
    <link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico">
    <link rel="apple-touch-icon image_src" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
    <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="http://stackoverflow.com/opensearch.xml">
    
    <script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/adzerk1_2_4_43adzerk2_2_17_45" async="" type="text/javascript"></script><script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/ga.js" async="" type="text/javascript"></script><script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/quant.js" async="" type="text/javascript"></script><script type="text/javascript" src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/jquery.js"></script>
    <script type="text/javascript" src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/stub.js"></script>
    <link rel="stylesheet" type="text/css" href="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/all.css">
    
    <meta name="relativepagescore" content="33212">
    <link rel="canonical" href="http://stackoverflow.com/questions/11300847/load-and-display-all-the-images-from-a-folder">
    <link rel="alternate" type="application/atom+xml" title="Feed for question 'Load and display all the images from a folder'" href="http://stackoverflow.com/feeds/question/11300847">
    <script type="text/javascript">
        
        StackExchange.ready(function () {
            StackExchange.using("postValidation", function () {
                StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
            });

            
            StackExchange.question.init({votesCast:[],autoShowCommentHelp:true,showAnswerHelp:true,totalCommentCount:3,shownCommentCount:3,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId:11300847});

            styleCode();

                StackExchange.realtime.subscribeToQuestion('1', '11300847');
            
                
        });
    </script>


    <script type="text/javascript">
        StackExchange.init({"stackAuthUrl":"https://stackauth.com","serverTime":1369355124,"styleCode":true,"enableUserHovercards":true,"site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","useNewStyleFavoriteTagsEditor":true,"enableSocialMediaInSharePopup":true},"user":{"fkey":"16e1237539096dfd23a2c353cb8945c3","isRegistered":true,"userId":2349960,"accountId":2724491,"gravatar":"<div class=\"\"><img src=\"http://www.gravatar.com/avatar/44515fd76d8e37b20e5b397eec5732f8?s=32&d=identicon&r=PG\" alt=\"\" width=\"32\" height=\"32\"></div>","profileUrl":"http://stackoverflow.com/users/2349960/phu-tri","notificationsUnviewedCount":1,"inboxUnviewedCount":0}});
        StackExchange.using.setCacheBreakers({"js/prettify-full.js":"6c261bebf56a","js/moderator.js":"f96f7e4ee5dc","js/full-anon.js":"0916c60ba5ef","js/full.js":"ee8dc25807f6","js/wmd.js":"24dacdd41d7b","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/mobile.js":"6eb68240242f","js/help.js":"fc9fb0517db2","js/tageditor.js":"450c9e8426fc","js/tageditornew.js":"b6c68ad4c7dd","js/inline-tag-editing.js":"8e84e8a137f7","js/revisions.js":"7273bb714bba","js/review.js":"56c3941a5bfc","js/tagsuggestions.js":"aa48ef6154df","js/post-validation.js":"4aec80fc0009","js/explore-qlist.js":"1c5bbd79b562"});
        
    </script>
    <script type="text/javascript">
        StackExchange.using("gps", function() {
             StackExchange.gps.init(true);
        });
    </script>
    
<script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/full.js" type="text/javascript" async=""></script><script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/post-validation.js" type="text/javascript" async=""></script><script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/prettify-full.js" type="text/javascript" async=""></script><script src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/wmd.js" type="text/javascript" async=""></script><script>try {  for(var lastpass_iter=0; lastpass_iter < document.forms.length; lastpass_iter++){    var lastpass_f = document.forms[lastpass_iter];    if(typeof(lastpass_f.lpsubmitorig)=="undefined"){      if (typeof(lastpass_f.submit) == "function") {        lastpass_f.lpsubmitorig = lastpass_f.submit;        lastpass_f.submit = function(){          var form = this;          try {            if (document.documentElement && 'createEvent' in document)            {              var forms = document.getElementsByTagName('form');              for (var i=0 ; i<forms.length ; ++i)                if (forms[i]==form)                {                  var element = document.createElement('lpformsubmitdataelement');                  element.setAttribute('formnum',i);                  element.setAttribute('from','submithook');                  document.documentElement.appendChild(element);                  var evt = document.createEvent('Events');                  evt.initEvent('lpformsubmit',true,false);                  element.dispatchEvent(evt);                  break;                }            }          } catch (e) {}          try {            form.lpsubmitorig();          } catch (e) {}        }      }    }  }} catch (e) {}</script></head>
<body class="question-page">
    <noscript><div id="noscript-padding"></div></noscript>
    <div id="notify-container"></div>
    <div id="overlay-header"></div>
    <div id="custom-header"></div>

    <div class="container">
        <div id="header">
            <div id="portalLink">
                <a class="genu" onclick="StackExchange.ready(function(){genuwine.click();});return false;">Stack Exchange</a>
                        <a class="unreadCount newNotices" title="you have unread notices">1</a>
            </div>
            <div id="topbar">
                <div id="hlinks">
                    
<span id="hlinks-user">        <span class="profile-triangle">▼</span><a href="http://stackoverflow.com/users/2349960/phu-tri" class="profile-link">Phú Trí</a>&nbsp;<a href="http://stackoverflow.com/users/2349960/phu-tri?tab=reputation"><span class="reputation-score" title="your reputation; view reputation changes" dir="ltr">1</span></a>
 <span class="lsep">|</span>

</span>
<span id="hlinks-nav"></span>
<span id="hlinks-custom">            <a href="http://chat.stackoverflow.com/">chat</a>

 <span class="lsep">|</span>
                <a href="http://meta.stackoverflow.com/">meta</a>

 <span class="lsep">|</span>
            <a href="http://stackoverflow.com/about">about</a>

 <span class="lsep">|</span>
        <a href="http://stackoverflow.com/faq">faq</a>
</span>
                </div>
                <div id="hsearch">
                    <form id="search" action="/search" method="get" autocomplete="off">
                        <div>
                            <input autocomplete="off" name="q" class="textbox" placeholder="search" tabindex="1" maxlength="240" size="28" type="text">
                        </div>
                    </form>
                </div>
            </div>
            <br class="cbt">
            <div id="hlogo">
                <a href="http://stackoverflow.com/">
                    Stack Overflow
                </a>
            </div>
            <div id="hmenus">
                <div class="nav mainnavs ">
                    <ul>
                            <li class="youarehere"><a id="nav-questions" href="http://stackoverflow.com/questions">Questions</a></li>
                            <li><a id="nav-tags" href="http://stackoverflow.com/tags">Tags</a></li>
                            <li><a id="nav-users" href="http://stackoverflow.com/users">Users</a></li>
                            <li><a id="nav-badges" href="http://stackoverflow.com/badges">Badges</a></li>
                            <li><a id="nav-unanswered" href="http://stackoverflow.com/unanswered">Unanswered</a></li>
                    </ul>
                </div>
                <div class="nav askquestion">
                    <ul>
                        <li>
                            <a id="nav-askquestion" href="http://stackoverflow.com/questions/ask">Ask Question</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        



        <div id="content">
            

<div itemscope="" itemtype="http://schema.org/Article">
<link itemprop="image" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
<div id="question-header">
    <h1 itemprop="name"><a href="http://stackoverflow.com/questions/11300847/load-and-display-all-the-images-from-a-folder" class="question-hyperlink">Load and display all the images from a folder</a></h1>
</div>
<div id="mainbar">



<div class="question" data-questionid="11300847" id="question">
    
                <div class="everyonelovesstackoverflow" id="adzerk1">
            </div>


    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input value="11300847" type="hidden">
    <a class="vote-up-off" title="This question shows research effort; it is useful and clear (click again to undo)">up vote</a>
    <span class="vote-count-post ">1</span>
    <a class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful (click again to undo)">down vote</a>
    
    <a class="star-off" href="#" title="This is a favorite question (click again to undo)">favorite</a>
    <div class="favoritecount"><b>2</b></div>   

</div>

            </td>
            
<td class="postcell">
<div>
    <div class="post-text" itemprop="description">
        <p>I want to read all the images in a folder using Java.</p>

<p><strong>When:</strong> I press a button in the Java application,<br>
<strong>It should:</strong></p>

<ul>
<li>ask for the directory's path in a popup,</li>
<li><strong>then</strong> load all the images from this directory,</li>
<li><strong>then</strong> display their names, dimension types and size.</li>
</ul>

<p>How to proceed?</p>

<p>I have the code for read the image and also for all image in the folder but how the things i told above can be done?</p>

<p>Any suggestion or help is welcome! Please provide reference links!</p>

    </div>
    <div class="post-taglist">
        <a href="http://stackoverflow.com/questions/tagged/java" class="post-tag" title="show questions tagged 'java'" rel="tag">java</a> <a href="http://stackoverflow.com/questions/tagged/image" class="post-tag" title="show questions tagged 'image'" rel="tag">image</a> <a href="http://stackoverflow.com/questions/tagged/file" class="post-tag" title="show questions tagged 'file'" rel="tag">file</a> 
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">









<div class="post-menu"><a href="http://stackoverflow.com/q/11300847/2349960" title="short permalink to this question" class="short-link" id="link-post-11300847">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/11300847/edit" class="suggest-edit-post" title="revise and improve this post">edit</a></div>            </td>
    <td class="post-signature" align="right">


    <div class="user-info user-hover">
        <div class="user-action-time">
                                         <a href="http://stackoverflow.com/posts/11300847/revisions" title="show all edits to this post">edited <span title="2012-07-02 21:22:40Z" class="relativetime">Jul 2 '12 at 21:22</span></a>

        </div>
        <div class="user-gravatar32">
            <a href="http://stackoverflow.com/users/453590/haylem"><div class=""><img src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/fbefde65228a384a59eb49e8a46c4e7b.jpg" alt="" height="32" width="32"></div></a>
        </div>
        <div class="user-details">
            <a href="http://stackoverflow.com/users/453590/haylem">haylem</a><br>
            <span class="reputation-score" title="reputation score" dir="ltr">7,933</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="17 silver badges"><span class="badge2"></span><span class="badgecount">17</span></span><span title="51 bronze badges"><span class="badge3"></span><span class="badgecount">51</span></span>
        </div>
    </div>
    </td>
    <td class="post-signature owner">
        

    <div class="user-info ">
        <div class="user-action-time">
                                    asked
 <span title="2012-07-02 20:41:14Z" class="relativetime">Jul 2 '12 at 20:41</span>
        </div>
        <div class="user-gravatar32">
            <a href="http://stackoverflow.com/users/1497114/kundanraj"><div class=""><img src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/4ee3f533d2fa5d8e59e9a5e7ec35698f.png" alt="" height="32" width="32"></div></a>
        </div>
        <div class="user-details">
            <a href="http://stackoverflow.com/users/1497114/kundanraj">kundanraj</a><br>
            <span class="reputation-score" title="reputation score" dir="ltr">11</span><span title="2 bronze badges"><span class="badge3"></span><span class="badgecount">2</span></span>
        </div>
    </div>

    </td>
    </tr>
    </tbody></table>
</div>
</td>
        </tr>


<tr>
<td class="votecell"></td>
<td>
    <div id="comments-11300847" class="comments">
        <table>
        <tbody>
                    
    <tr id="comment-14868838" class="comment">
        <td class="comment-actions"><table><tbody><tr>
<td class="comment-score">
<span title="number of 'useful comment' votes received" class="warm">11</span>
</td>
<td>
&nbsp;
</td></tr>
</tbody></table></td>
        <td class="comment-text"><div><span class="comment-copy">show us what you have, and tell us where you are getting stuck <i>exactly</i> if you expect help on this. <a href="http://stackoverflow.com/questions/how-to-ask">How to Ask</a></span> –&nbsp;<a href="http://stackoverflow.com/users/1106367/codesparkle" title="4718 reputation" class="comment-user">codesparkle</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14868838_11300847"><span title="2012-07-02 20:43:20Z" class="relativetime-clean">Jul 2 '12 at 20:43</span></a></span><span class="edited-yes" title="this comment was edited 2 times"></span></div></td>
    </tr>
            
    <tr id="comment-14869185" class="comment">
        <td class="comment-actions"><table><tbody><tr>
<td class="comment-score">
<span title="number of 'useful comment' votes received" class="cool">1</span>
</td>
<td>
&nbsp;
</td></tr>
</tbody></table></td>
        <td class="comment-text"><div><span class="comment-copy">Since your question is pretty generic, I can but guess that this is you're after: <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html" rel="nofollow">docs.oracle.com/javase/tutorial/uiswing/components/…</a> This is one way of doing it.</span> –&nbsp;<a href="http://stackoverflow.com/users/574479/biziclop" title="15650 reputation" class="comment-user">biziclop</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869185_11300847"><span title="2012-07-02 21:02:10Z" class="relativetime-clean">Jul 2 '12 at 21:02</span></a></span></div></td>
    </tr>
            
    <tr id="comment-14869340" class="comment">
        <td></td>
        <td class="comment-text"><div><span class="comment-copy">@kundanraj: if this is homework, please tag is as such.</span> –&nbsp;<a href="http://stackoverflow.com/users/453590/haylem" title="7933 reputation" class="comment-user">haylem</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869340_11300847"><span title="2012-07-02 21:10:03Z" class="relativetime-clean">Jul 2 '12 at 21:10</span></a></span></div></td>
    </tr>

        </tbody>
    
        </table>
    </div>
    
</td>
</tr>            </tbody></table>    
</div>


<div id="answers">

    <a name="tab-top"></a>
    <div id="answers-header">
        <div class="subheader answers-subheader">
            <h2>
                    1 Answer
            </h2>
            <div id="tabs">
                <a href="http://stackoverflow.com/questions/11300847/load-and-display-all-the-images-from-a-folder?answertab=active#tab-top" title="Answers with the latest activity first">active</a>
<a href="http://stackoverflow.com/questions/11300847/load-and-display-all-the-images-from-a-folder?answertab=oldest#tab-top" title="Answers in the order they were provided">oldest</a>
<a class="youarehere" href="http://stackoverflow.com/questions/11300847/load-and-display-all-the-images-from-a-folder?answertab=votes#tab-top" title="Answers with the highest score first">votes</a>

            </div>
        </div>    
    </div>    




  
<a name="11301085"></a>
<div id="answer-11301085" class="answer" data-answerid="11301085">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input value="11301085" type="hidden">
    <a class="vote-up-off" title="This answer is useful (click again to undo)">up vote</a>
    <span class="vote-count-post ">5</span>
    <a class="vote-down-off" title="This answer is not useful (click again to undo)">down vote</a>
    

</div>

            </td>
            


<td class="answercell">
    <div class="post-text"><p><em>Untested because not on a machine with
 a JDK installed, so bear with me, that's all typed-in "as-is", but 
should get you started (expect a rush of downvotes...)</em></p>

<h1>Loading all the Images from a Folder</h1>

<pre style="" class="lang-java prettyprint prettyprinted"><code><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">awt</span><span class="pun">.</span><span class="pln">image</span><span class="pun">.</span><span class="typ">BufferedImage</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">io</span><span class="pun">.</span><span class="typ">File</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">io</span><span class="pun">.</span><span class="typ">FilenameFilter</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">io</span><span class="pun">.</span><span class="typ">IOException</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">import</span><span class="pln"> javax</span><span class="pun">.</span><span class="pln">imageio</span><span class="pun">.</span><span class="typ">ImageIO</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">Test</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

    </span><span class="com">// File representing the folder that you select using a FileChooser</span><span class="pln">
    </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">File</span><span class="pln"> dir </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">File</span><span class="pun">(</span><span class="str">"PATH_TO_YOUR_DIRECTORY"</span><span class="pun">);</span><span class="pln">

    </span><span class="com">// array of supported extensions (use a List if you prefer)</span><span class="pln">
    </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">String</span><span class="pun">[]</span><span class="pln"> EXTENSIONS </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">String</span><span class="pun">[]{</span><span class="pln">
        </span><span class="str">"gif"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"png"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"bmp"</span><span class="pln"> </span><span class="com">// and other formats you need</span><span class="pln">
    </span><span class="pun">};</span><span class="pln">
    </span><span class="com">// filter to identify images based on their extensions</span><span class="pln">
    </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">FilenameFilter</span><span class="pln"> IMAGE_FILTER </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">FilenameFilter</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="lit">@Override</span><span class="pln">
        </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">boolean</span><span class="pln"> accept</span><span class="pun">(</span><span class="kwd">final</span><span class="pln"> </span><span class="typ">File</span><span class="pln"> dir</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> name</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">final</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> ext </span><span class="pun">:</span><span class="pln"> EXTENSIONS</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">name</span><span class="pun">.</span><span class="pln">endsWith</span><span class="pun">(</span><span class="str">"."</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> ext</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">true</span><span class="pun">);</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    </span><span class="pun">};</span><span class="pln">

    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> main</span><span class="pun">(</span><span class="typ">String</span><span class="pun">[]</span><span class="pln"> args</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">dir</span><span class="pun">.</span><span class="pln">isDirectory</span><span class="pun">())</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="com">// make sure it's a directory</span><span class="pln">
            </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">final</span><span class="pln"> </span><span class="typ">File</span><span class="pln"> f </span><span class="pun">:</span><span class="pln"> dir</span><span class="pun">.</span><span class="pln">listFiles</span><span class="pun">(</span><span class="pln">IMAGE_FILTER</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="typ">BufferedImage</span><span class="pln"> img </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">

                </span><span class="kwd">try</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    img </span><span class="pun">=</span><span class="pln"> </span><span class="typ">ImageIO</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="pln">f</span><span class="pun">);</span><span class="pln">

                    </span><span class="com">// you probably want something more involved here</span><span class="pln">
                    </span><span class="com">// to display in your UI</span><span class="pln">
                    </span><span class="typ">System</span><span class="pun">.</span><span class="pln">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"image: "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> f</span><span class="pun">.</span><span class="pln">getName</span><span class="pun">());</span><span class="pln">
                    </span><span class="typ">System</span><span class="pun">.</span><span class="pln">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">" width : "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> img</span><span class="pun">.</span><span class="pln">getWidth</span><span class="pun">());</span><span class="pln">
                    </span><span class="typ">System</span><span class="pun">.</span><span class="pln">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">" height: "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> img</span><span class="pun">.</span><span class="pln">getHeight</span><span class="pun">());</span><span class="pln">
                    </span><span class="typ">System</span><span class="pun">.</span><span class="pln">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">" size  : "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> f</span><span class="pun">.</span><span class="pln">length</span><span class="pun">());</span><span class="pln">
                </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">catch</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">final</span><span class="pln"> </span><span class="typ">IOException</span><span class="pln"> e</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    </span><span class="com">// handle errors here</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span></code></pre>

<h1>APIs Used</h1>

<p>This is relatively simple to do and uses only standard JDK-packaged classes:</p>

<ul>
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/io/File.html" rel="nofollow"><code>File</code></a></li>
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/io/FilenameFilter.html" rel="nofollow"><code>FilenameFilter</code></a></li>
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html" rel="nofollow"><code>BufferedImage</code></a></li>
<li><a href="http://docs.oracle.com/javase/6/docs/api/javax/imageio/ImageIO.html" rel="nofollow"><code>ImageIO</code></a></li>
</ul>

<p>These sessions of the <a href="http://docs.oracle.com/javase/tutorial" rel="nofollow">Java Tutorial</a> might help you as well:</p>

<ul>
<li><a href="http://docs.oracle.com/javase/tutorial/2d/images/loadimage.html" rel="nofollow">Reading/Loading an Image</a></li>
<li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html" rel="nofollow">How to Use Icons</a></li>
<li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html" rel="nofollow">How to Use File Choosers</a></li>
</ul>

<h1>Possible Enhancements</h1>

<ul>
<li>Use Apache Commons <code>FilenameUtils</code> to extract files' extensions</li>
<li>Detect files based on actual mime-types or content, not based on extensions</li>
<li>I leave UI code up to you. As I'm unaware if this is homework or not, I don't want to provide a full solution. But to continue:
<ul>
<li>Look at a <code>FileChooser</code> to select the folder.</li>
<li>I assume you already know how to make frames/windows/dialogs.</li>
<li>Read the <a href="http://docs.oracle.com/javase/tutorial" rel="nofollow">Java Tutorial</a> <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html" rel="nofollow">How to Use Icons</a> sections, which teaches you how to display and label them.</li>
</ul></li>
<li>I left out some issues to be dealt with:
<ul>
<li>Exception handling</li>
<li>Folders with evil endigs (say you have a folder "TryMeIAmEvil.png")</li>
</ul></li>
</ul>

<p>By combining all of the above, it's pretty easy to do.</p>
</div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">









<div class="post-menu"><a href="http://stackoverflow.com/a/11301085/2349960" title="short permalink to this answer" class="short-link" id="link-post-11301085">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/11301085/edit" class="suggest-edit-post" title="revise and improve this post">edit</a></div>                    </td>
    <td class="post-signature" align="right">


    <div class="user-info ">
        <div class="user-action-time">
                                         <a href="http://stackoverflow.com/posts/11301085/revisions" title="show all edits to this post">edited <span title="2012-07-02 21:35:54Z" class="relativetime">Jul 2 '12 at 21:35</span></a>

        </div>
        <div class="user-gravatar32">
            
        </div>
        <div class="user-details">
            <br>
            
        </div>
    </div>
    </td>
            


    <td class="post-signature" align="right">   
       

    

    <div class="user-info user-hover">
        <div class="user-action-time">
                                    answered
 <span title="2012-07-02 20:58:50Z" class="relativetime">Jul 2 '12 at 20:58</span>
        </div>
        <div class="user-gravatar32">
            <a href="http://stackoverflow.com/users/453590/haylem"><div class=""><img src="java%20-%20Load%20and%20display%20all%20the%20images%20from%20a%20folder%20-%20Stack%20Overflow_files/fbefde65228a384a59eb49e8a46c4e7b.jpg" alt="" height="32" width="32"></div></a>
        </div>
        <div class="user-details">
            <a href="http://stackoverflow.com/users/453590/haylem">haylem</a><br>
            <span class="reputation-score" title="reputation score" dir="ltr">7,933</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="17 silver badges"><span class="badge2"></span><span class="badgecount">17</span></span><span title="51 bronze badges"><span class="badge3"></span><span class="badgecount">51</span></span>
        </div>
    </div>

    </td>
    </tr>
    </tbody></table>
</td>
        </tr>



<tr>
<td class="votecell"></td>
<td>
    <div id="comments-11301085" class="comments">
        <table>
        <tbody>
                    
    <tr id="comment-14869605" class="comment">
        <td></td>
        <td class="comment-text"><div><span class="comment-copy">everything went better than expected? ;)</span> –&nbsp;<a href="http://stackoverflow.com/users/1106367/codesparkle" title="4718 reputation" class="comment-user">codesparkle</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869605_11301085"><span title="2012-07-02 21:23:19Z" class="relativetime-clean">Jul 2 '12 at 21:23</span></a></span></div></td>
    </tr>
            
    <tr id="comment-14869629" class="comment">
        <td></td>
        <td class="comment-text"><div><span class="comment-copy">@codesparkle:
 I don't, maybe that code actually works? :) Usually when you post 
something that fails, you get quickly trashed for submitted crappy code.
 Or maybe it's just not rush-hour yet. Plus as I went I realized the OP 
was probably asking for homework so I didn't keep on going.</span> –&nbsp;<a href="http://stackoverflow.com/users/453590/haylem" title="7933 reputation" class="comment-user">haylem</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869629_11301085"><span title="2012-07-02 21:24:48Z" class="relativetime-clean">Jul 2 '12 at 21:24</span></a></span></div></td>
    </tr>
            
    <tr id="comment-14869662" class="comment">
        <td></td>
        <td class="comment-text"><div><span class="comment-copy">+1 you did good for typing it without an IDE :)</span> –&nbsp;<a href="http://stackoverflow.com/users/1133011/david-kroukamp" title="19306 reputation" class="comment-user">David Kroukamp</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869662_11301085"><span title="2012-07-02 21:25:54Z" class="relativetime-clean">Jul 2 '12 at 21:25</span></a></span></div></td>
    </tr>
            
    <tr id="comment-14869688" class="comment">
        <td></td>
        <td class="comment-text"><div><span class="comment-copy">@DavidKroukamp:
 it's not too hard for relatively simple things once you know the APIs, 
and the Javadoc and Java Tutorial are online to help refresh memories 
and put pieces back together. Remembering imports is usually the tricky 
part (as I almost never type any now that IDEs do it for me...)</span> –&nbsp;<a href="http://stackoverflow.com/users/453590/haylem" title="7933 reputation" class="comment-user">haylem</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869688_11301085"><span title="2012-07-02 21:27:09Z" class="relativetime-clean">Jul 2 '12 at 21:27</span></a></span></div></td>
    </tr>
            
    <tr id="comment-14869801" class="comment">
        <td></td>
        <td class="comment-text"><div><span class="comment-copy">Lol yes imports are fatherless :). I have corrected your code where neccessary but it wasnt much so my +1 still stands great job</span> –&nbsp;<a href="http://stackoverflow.com/users/1133011/david-kroukamp" title="19306 reputation" class="comment-user">David Kroukamp</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment14869801_11301085"><span title="2012-07-02 21:33:05Z" class="relativetime-clean">Jul 2 '12 at 21:33</span></a></span></div></td>
    </tr>

        </tbody>
    
        </table>
    </div>
    <a id="comments-link-11301085" class="comments-link" data-comments-count="1" title="expand to show all comments on this post">show <b>1</b> more comment</a>
</td>
</tr>
    </tbody></table>
</div>
    <a name="new-answer"></a>
    <form id="post-form" action="/questions/11300847/answer/submit" method="post" class="post-form">
        <input id="post-id" value="11300847" type="hidden">
        <h2 class="space">Your Answer</h2>



    
<script type="text/javascript">
    StackExchange.ready(function() {
        initTagRenderer("".split(" "), "".split(" "));
         
        prepareEditor({
            heartbeatType: 'answer',
            bindNavPrevention: true,
            postfix: "",
            onDemand: false,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
        });
        

    });  
</script>


<div id="post-editor" class="post-editor">

    <div style="position: relative;">     
        <div class="wmd-container">
            <div id="wmd-button-bar" class="wmd-button-bar"><ul class="wmd-button-row" id="wmd-button-row"><li title="Strong &lt;strong&gt; Ctrl+B" id="wmd-bold-button" style="left: 0px;" class="wmd-button"><span style="background-position: 0px 0px;"></span></li><li title="Emphasis &lt;em&gt; Ctrl+I" id="wmd-italic-button" style="left: 25px;" class="wmd-button"><span style="background-position: -20px 0px;"></span></li><li id="wmd-spacer1" class="wmd-spacer wmd-spacer1"></li><li title="Hyperlink &lt;a&gt; Ctrl+L" id="wmd-link-button" style="left: 75px;" class="wmd-button"><span style="background-position: -40px 0px;"></span></li><li title="Blockquote &lt;blockquote&gt; Ctrl+Q" id="wmd-quote-button" style="left: 100px;" class="wmd-button"><span style="background-position: -60px 0px;"></span></li><li title="Code Sample &lt;pre&gt;&lt;code&gt; Ctrl+K" id="wmd-code-button" style="left: 125px;" class="wmd-button"><span style="background-position: -80px 0px;"></span></li><li title="Image &lt;img&gt; Ctrl+G" id="wmd-image-button" style="left: 150px;" class="wmd-button"><span style="background-position: -100px 0px;"></span></li><li id="wmd-spacer2" class="wmd-spacer wmd-spacer2"></li><li title="Numbered List &lt;ol&gt; Ctrl+O" id="wmd-olist-button" style="left: 200px;" class="wmd-button"><span style="background-position: -120px 0px;"></span></li><li title="Bulleted List &lt;ul&gt; Ctrl+U" id="wmd-ulist-button" style="left: 225px;" class="wmd-button"><span style="background-position: -140px 0px;"></span></li><li title="Heading &lt;h1&gt;/&lt;h2&gt; Ctrl+H" id="wmd-heading-button" style="left: 250px;" class="wmd-button"><span style="background-position: -160px 0px;"></span></li><li title="Horizontal Rule &lt;hr&gt; Ctrl+R" id="wmd-hr-button" style="left: 275px;" class="wmd-button"><span style="background-position: -180px 0px;"></span></li><li id="wmd-spacer3" class="wmd-spacer wmd-spacer3"></li><li title="Undo - Ctrl+Z" id="wmd-undo-button" style="left: 325px;" class="wmd-button"><span style="background-position: -200px -20px;"></span></li><li title="Redo - Ctrl+Y" id="wmd-redo-button" style="left: 350px;" class="wmd-button"><span style="background-position: -220px -20px;"></span></li><li title="Markdown Editing Help" style="right: 0px;" id="wmd-help-button" class="wmd-button wmd-help-button active-help"><span style="background-position: -240px 0px;"></span></li><div style="right: -8px; width: 668px; top: 25px;" id="mdhelp" class="mdhelp">
    <ul id="mdhelp-tabs" class="mdhelp-tabs">
        <li data-tab="mdhelp-links" data-buttons="link">Links</li>
        <li data-tab="mdhelp-images" data-buttons="image">Images</li>
        <li data-tab="mdhelp-styles" data-buttons="bold,italic,heading">Styling/Headers</li>
        <li data-tab="mdhelp-lists" data-buttons="olist,ulist">Lists</li>
        <li data-tab="mdhelp-blockquotes" data-buttons="quote">Blockquotes</li>
        <li data-tab="mdhelp-code" data-buttons="code">Code</li>
        <li data-tab="mdhelp-html">HTML</li>
        <li style="float:right"><a href="http://stackoverflow.com/editing-help" target="_blank">advanced help »</a></li>
    </ul>
    
    <div class="mdhelp-tab" id="mdhelp-links">
            <p>
                In most cases, a plain URL will be recognized as such and automatically linked:
            </p>
            <pre>Visit http://area51.stackexchange.com/ regularly!
Use angle brackets to force linking: Have you seen &lt;http://superuser.com&gt;?
</pre>
            <p>
                To create fancier links, use Markdown:
            </p>
                <pre>Here's [a link](http://www.example.com/)! And a reference-style link to [a panda][1].
References don't have to be [numbers][question].

 [1]: http://notfound.stackexchange.com/
 [question]: http://english.stackexchange.com/questions/11481
</pre>
                <p>You can add tooltips to links:</p>
<pre>Click [here](http://diy.stackexchange.com<span class="spaces">&nbsp;</span>"this text appears when you mouse over")!
This works with [reference links][blog] as well.

 [blog]: http://blog.stackoverflow.com/<span class="spaces">&nbsp;</span>"click here for updates"
</pre>
    </div>

    <div class="mdhelp-tab" id="mdhelp-images">
        <p>Images are exactly like links, but they have an exclamation point in front of them:</p>
        <pre>![a busy cat](http://sstatic.net/stackoverflow/img/error-lolcat-problemz.jpg)
![two muppets][1]

 [1]: http://i.imgur.com/I5DFV.jpg "tooltip"
</pre>
        <p>
            The word in square brackets is the alt text, which gets displayed if the browser
            can't show the image. Be sure to include meaningful alt text for screen-reading
            software.
        </p>
   
    </div>
    <div class="mdhelp-tab" id="mdhelp-styles">
        <div class="col1">
            <p>Be sure to use text styling sparingly; only where it helps readability.</p>
                <pre>*This is italicized*, and so
is _this_.

**This is bold**, just like __this__.

You can ***combine*** them
if you ___really have to___.
</pre>
        
        </div>
        <div class="col2">
            <p>
                To break your text into sections, you can use headers:
            </p>
                <pre>A Large Header
==============

Smaller Subheader
-----------------
</pre>
            <p>
                Use hash marks if you need several levels of headers:</p>
    <pre># Header 1 #
## Header 2 ##
### Header 3 ###
</pre>

            
        </div>

    </div>
    <div class="mdhelp-tab" id="mdhelp-lists">
        <p>Both bulleted and numbered lists are possible:</p>
        <div class="col1">
<pre>-<span class="spaces">&nbsp;</span>Use a minus sign for a bullet
+<span class="spaces">&nbsp;</span>Or plus sign
*<span class="spaces">&nbsp;</span>Or an asterisk

1.<span class="spaces">&nbsp;</span>Numbered lists are easy
2.<span class="spaces">&nbsp;</span>Markdown keeps track of
   the numbers for you
7.<span class="spaces">&nbsp;</span>So this will be item 3.
</pre>
        </div>
        <div class="col2">
<pre>1.<span class="spaces">&nbsp;</span>Lists in a list item:
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>-<span class="spaces">&nbsp;</span>Indented four spaces.
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>*<span class="spaces">&nbsp;</span>indented eight spaces.
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>-<span class="spaces">&nbsp;</span>Four spaces again.
2.<span class="spaces">&nbsp;&nbsp;</span>You can have multiple
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>paragraphs in a list items.
<span class="spaces">&nbsp;</span>
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>Just be sure to indent.
</pre>        
        </div>
    </div>

    <div class="mdhelp-tab" id="mdhelp-blockquotes">
        <div class="col1">
            <pre>&gt; Create a blockquote by
&gt; prepending “&gt;” to each line.
&gt;
&gt; Other formatting also works here, e.g.
&gt;
&gt; 1. Lists or
&gt; 2. Headings:
&gt;
&gt; ## Quoted Heading ##
            </pre>
        </div>
        <div class="col2">
                <p>
                    You can even put blockquotes in blockquotes:
                </p>
                <pre>&gt; A standard blockquote is indented
&gt; &gt; A nested blockquote is indented more
&gt; &gt; &gt; &gt; You can nest to any depth.
</pre>
        </div>
    </div>

    <div class="mdhelp-tab" id="mdhelp-code">
        <p>
            To create code blocks or other preformatted text, indent by four spaces:
        </p>
        <pre><span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>This will be displayed in a monospaced font. The first four spaces
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>will be stripped off, but all other whitespace will be preserved.
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>Markdown and HTML are turned off in code blocks:
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;i&gt;This is not italic&lt;/i&gt;, and [this is not a link](http://example.com)
</pre>
        <p>
            To create not a block, but an inline code span, use backticks:
        </p>
        <pre>The `$` character is just a shortcut for `window.jQuery`.
</pre>
        <p>
            If you want to have a preformatted block within a list, indent by eight spaces:
        </p>
        <pre>1. This is normal text.
2. So is this, but now follows a code block:
<span class="spaces">&nbsp;</span>
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>Skip a line and indent eight spaces.
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>That's four spaces for the list
<span class="spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>and four to trigger the code block.
</pre>
    </div>

    <div class="mdhelp-tab" id="mdhelp-html">
        <p>
            If you need to do something that Markdown can't handle, use HTML. Note that
            <a href="http://meta.stackoverflow.com/questions/1777/what-html-tags-are-allowed" target="_blank">we only support a very strict subset of HTML!</a>
        </p>
        <pre>Strikethrough humor is &lt;strike&gt;funny&lt;/strike&gt;.
</pre>
        <p>
            Markdown is smart enough not to mangle your span-level HTML:
        </p>
        <pre>&lt;b&gt;Markdown works *fine* in here.&lt;/b&gt;
</pre>
        <p>
            Block-level HTML elements have a few restrictions:
        </p>
        <ol>
            <li>They must be separated from surrounding text by blank lines.</li>
            <li>The begin and end tags of the outermost block element must not be indented.</li>
            <li>Markdown can't be used within HTML blocks.</li>
        </ol>
        <br>
        <pre>&lt;pre&gt;
    You can &lt;em&gt;not&lt;/em&gt; use Markdown in here.
&lt;/pre&gt;
</pre>
    </div>

    <div class="cbt"></div>
</div></ul></div>
            <div style="clear: both; height: 23px;"></div><textarea id="wmd-input" class="wmd-input processed" name="post-text" cols="92" rows="15" tabindex="101" data-min-length=""></textarea>
        <div style="margin-right: 0px;" class="grippie"></div></div>
    </div>

    <div class="fl" style="margin-top: 8px; height:24px;">&nbsp;</div>
    <div id="draft-saved" class="draft-saved community-option fl" style="margin-top: 8px; height:24px; display:none;">draft saved</div>

    <div id="draft-discarded" class="draft-discarded community-option fl" style="margin-top: 8px; height:24px; display:none;">draft discarded</div>



    <div id="wmd-preview" class="wmd-preview"></div>
    <div></div>
    <div class="edit-block">
        <input id="fkey" name="fkey" value="16e1237539096dfd23a2c353cb8945c3" type="hidden">
        <input id="author" name="author" type="text">
    </div>
</div>
        <div style="position: relative;"> 
        </div>
           
            <div class="form-submit cbt">
            <input id="submit-button" value="Post Your Answer" tabindex="110" type="submit">
            <a href="#" class="discard-answer dno">discard</a>
        </div>
    </form>



        <h2 class="bottom-notice">
                Not the answer you're looking for? 
            Browse other questions tagged <a href="http://stackoverflow.com/questions/tagged/java" class="post-tag" title="show questions tagged 'java'" rel="tag">java</a> <a href="http://stackoverflow.com/questions/tagged/image" class="post-tag" title="show questions tagged 'image'" rel="tag">image</a> <a href="http://stackoverflow.com/questions/tagged/file" class="post-tag" title="show questions tagged 'file'" rel="tag">file</a> 
                or <a href="http://stackoverflow.com/questions/ask">ask your own question</a>.
        </h2>
</div>
</div>
<div id="sidebar" class="show-votes">



     <script type="text/javascript">
         window.showNewUser = false;

     </script>
    <div class="module newuser newuser-greeting" id="newuser-box" style="display:none;">
        <h4>Hello World!</h4>
        <div>
            <p>This is a collaboratively edited question and answer site for <b>professional and enthusiast programmers</b>. It's 100% free, no registration required.</p>
            <p class="ar">
                    <a href="http://stackoverflow.com/about?mnu=1">about »</a>&nbsp;&nbsp;&nbsp;
                <a href="http://stackoverflow.com/faq?mnu=1">faq »</a>
            </p>
        </div>
    </div>
     <script type="text/javascript">
        if (showNewUser) {
            document.getElementById('newuser-box').style.display = '';
        }
     </script>
        <div class="module question-stats">
        <p class="label-key">tagged</p>
        <div class="tagged"><a href="http://stackoverflow.com/questions/tagged/java" class="post-tag" title="show questions tagged 'java'" rel="tag">java</a>&nbsp;<span class="item-multiplier"><span class="item-multiplier-x">×</span>&nbsp;<span class="item-multiplier-count">422604</span></span><br>
<a href="http://stackoverflow.com/questions/tagged/image" class="post-tag" title="show questions tagged 'image'" rel="tag">image</a>&nbsp;<span class="item-multiplier"><span class="item-multiplier-x">×</span>&nbsp;<span class="item-multiplier-count">33047</span></span><br>
<a href="http://stackoverflow.com/questions/tagged/file" class="post-tag" title="show questions tagged 'file'" rel="tag">file</a>&nbsp;<span class="item-multiplier"><span class="item-multiplier-x">×</span>&nbsp;<span class="item-multiplier-count">21485</span></span><br>
</div>
        <table id="qinfo">
            <tbody><tr>
                <td><p class="label-key">asked</p></td>
                <td style="padding-left:10px"><p class="label-key" title="2012-07-02 20:41:14Z"><b>10 months ago</b></p></td>
            </tr>
            <tr>
                <td><p class="label-key">viewed</p></td>

                <td style="padding-left:10px">
                    <p class="label-key">
                        <b>2042 times</b>
                    </p>
                </td>
            </tr>
            <tr>
                <td><p class="label-key">active</p></td>
                <td style="padding-left:10px"><p class="label-key"><b><a href="http://stackoverflow.com/questions/11300847/load-and-display-all-the-images-from-a-folder?lastactivity" class="lastactivity-link" title="2013-01-19 05:55:16Z">4 months ago</a></b></p></td>
            </tr>
        </tbody></table>
    </div>
    
<div class="module community-bulletin" data-tracker="cb=1">
    <h4>Community Bulletin</h4>
    <div class="related">
        <div class="spacer">
            <div class="bulletin-item-type event-date">event</div>
            <div class="bulletin-item-content">
                <a href="http://apptivate.ms/?cb=1" class="question-hyperlink" target="_blank">Port apps to win free stuff!</a> <span class="event-date" style="white-space: nowrap;">– now through June 7</span>
            </div>
            <br class="cbt">
        </div>

    </div>
</div>    
                    <script type="text/javascript">
                    var scriptSrc = "http://engine.adzerk.net/z/8277/adzerk1_2_4_43,adzerk2_2_17_45?keywords=java,image,file,x-user-registered";
                    if (document.referrer) {
                        if (/\?/.test(scriptSrc))
                            scriptSrc += "&";
                        else
                            scriptSrc += "?";
                        scriptSrc += "xReferrer=" + document.referrer;
                    }
                    StackExchange.ready(function() {
                        var z = document.createElement("script");
                        z.type = "text/javascript";
                        z.async = "true";
                        z.src = scriptSrc;
                        var s = document.getElementsByTagName("script")[0];
                        s.parentNode.insertBefore(z, s);
                    });
                </script>
            <div class="everyonelovesstackoverflow" id="adzerk2">
            </div>
    <div id="hireme">
        <script type="text/javascript">
            window.careers_adurl="http://careers.stackoverflow.com/gethired/js",window.careers_cssurl="//careerscdn.sstatic.net/careers/gethired/sidebar.min.css?v=7ae83073b37e",window.careers_leaderboardcssurl="//careerscdn.sstatic.net/careers/gethired/ninja.min.css?v=78ccbfa5c59f",window.careers_companycssurl="//careerscdn.sstatic.net/careers/gethired/company",window.careers_adselector="div.hireme, div#hireme",StackExchange.ready(function(){$.ajax({url:"//careerscdn.sstatic.net/careers/gethired/loader.min.js?v=607ab2dda910",dataType:"script",cache:!0})})
        </script>
    </div>



    
  
    
    <div class="module sidebar-related">
        <h4 id="h-related">Related</h4>
        <div class="related" data-tracker="rq=1">
            <div class="spacer">
<a href="http://stackoverflow.com/q/1123921?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">0</div>
</a>
<a href="http://stackoverflow.com/questions/1123921/no-images-displayed-when-website-called-from-self-written-webserver?rq=1" class="question-hyperlink">No images displayed when website called from self written webserver</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/3115777?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">1</div>
</a>
<a href="http://stackoverflow.com/questions/3115777/saving-multiple-images-in-a-single-file?rq=1" class="question-hyperlink">Saving Multiple Images in a Single File</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/5126120?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes default">0</div>
</a>
<a href="http://stackoverflow.com/questions/5126120/display-an-image-from-images-folder-if-a-value-equals-something?rq=1" class="question-hyperlink">Display an image from images folder if a value equals something</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/6153829?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes default">1</div>
</a>
<a href="http://stackoverflow.com/questions/6153829/concatenating-images-from-a-folder?rq=1" class="question-hyperlink">Concatenating images from a folder</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/7792942?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">1</div>
</a>
<a href="http://stackoverflow.com/questions/7792942/load-all-images-from-folder-in-android?rq=1" class="question-hyperlink">Load all images from folder in Android</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/9887724?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">0</div>
</a>
<a href="http://stackoverflow.com/questions/9887724/how-to-display-all-the-images-in-a-folder-with-html-python-and-cherrypy?rq=1" class="question-hyperlink">How to display all the images in a folder with HTML, python and cherrypy</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/10127464?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">1</div>
</a>
<a href="http://stackoverflow.com/questions/10127464/find-all-images-in-folder-with-javascript?rq=1" class="question-hyperlink">Find all images in folder with Javascript</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/13761394?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">0</div>
</a>
<a href="http://stackoverflow.com/questions/13761394/how-to-display-all-the-files-from-a-directory-folder?rq=1" class="question-hyperlink">How to display all the files from a directory (folder)</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/14802543?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes default">1</div>
</a>
<a href="http://stackoverflow.com/questions/14802543/displaying-all-images-within-a-folder-using-php?rq=1" class="question-hyperlink">Displaying all Images within a Folder using php</a>
</div>
<div class="spacer">
<a href="http://stackoverflow.com/q/15445409?rq=1" title="Vote score (upvotes - downvotes)">
        <div class="answer-votes answered-accepted default">0</div>
</a>
<a href="http://stackoverflow.com/questions/15445409/creating-an-image-of-a-disk-with-null-files?rq=1" class="question-hyperlink">Creating an 'image' of a disk with null files</a>
</div>

        </div>
    </div>
</div>

<div id="feed-link">
    <div id="feed-link-text"><a href="http://stackoverflow.com/feeds/question/11300847" title="feed of this question and its answers"><span class="feed-icon"></span>question feed</a></div>
</div>
<script type="text/javascript">
StackExchange.ready(function(){$.get('/posts/11300847/ivc/2c84');});
</script>
<noscript>
    <div><img src="/posts/11300847/ivc/2c84" class="dno" alt="" width="0" height="0"></div>
</noscript><div style="display:none" id="prettify-lang">lang-java</div></div>



        </div>
    </div>
    <div id="footer" class="categories">
        <div class="footerwrap">
            <div id="footer-menu">
                <div class="top-footer-links">
                        <a href="http://stackoverflow.com/about">about</a>
                    <a href="http://stackoverflow.com/faq">faq</a>
                    <a href="http://blog.stackexchange.com/?blb=1">blog</a>
                        <a href="http://chat.stackoverflow.com/">chat</a>
                    <a href="http://data.stackexchange.com/">data</a>
                    <a href="http://stackexchange.com/legal">legal</a>
                    <a href="http://stackexchange.com/legal/privacy-policy">privacy policy</a>
                    <a href="http://stackexchange.com/about/hiring">jobs</a>
                    <a href="http://engine.adzerk.net/redirect/0/2776/2751/0/4de3c60f719c4dfcb1a57531c7050090/0">advertising info</a>

                    <a onclick='StackExchange.switchMobile("on", "/questions/11300847/load-and-display-all-the-images-from-a-folder")'>mobile</a>
                    <b><a href="http://stackoverflow.com/help">contact us</a></b>
                        <b><a href="http://meta.stackoverflow.com/">feedback</a></b>
                </div>
                <div id="footer-sites">
                <table>
    <tbody><tr>
            <th colspan="3">
                Technology
            </th>
            <th>
                Life / Arts
            </th>
            <th>
                Culture / Recreation
            </th>
            <th>
                Science
            </th>
            <th>
                Other
            </th>
    </tr>
    <tr>
            <td>
                <ol>
                        <li><a href="http://stackoverflow.com/" title="professional and enthusiast programmers">Stack Overflow</a></li>
                        <li><a href="http://serverfault.com/" title="professional system and network administrators">Server Fault</a></li>
                        <li><a href="http://superuser.com/" title="computer enthusiasts and power users">Super User</a></li>
                        <li><a href="http://webapps.stackexchange.com/" title="power users of web applications">Web Applications</a></li>
                        <li><a href="http://askubuntu.com/" title="Ubuntu users and developers">Ask Ubuntu</a></li>
                        <li><a href="http://webmasters.stackexchange.com/" title="pro webmasters">Webmasters</a></li>
                        <li><a href="http://gamedev.stackexchange.com/" title="professional and independent game developers">Game Development</a></li>
                        <li><a href="http://tex.stackexchange.com/" title="users of TeX, LaTeX, ConTeXt, and related typesetting systems">TeX - LaTeX</a></li>
                            </ol></td><td><ol>
                        <li><a href="http://programmers.stackexchange.com/" title="professional programmers interested in conceptual questions about software development">Programmers</a></li>
                        <li><a href="http://unix.stackexchange.com/" title="users of Linux, FreeBSD and other Un*x-like operating systems.">Unix &amp; Linux</a></li>
                        <li><a href="http://apple.stackexchange.com/" title="power users of Apple hardware and software">Ask Different (Apple)</a></li>
                        <li><a href="http://wordpress.stackexchange.com/" title="WordPress developers and administrators">WordPress Answers</a></li>
                        <li><a href="http://gis.stackexchange.com/" title="cartographers, geographers and GIS professionals">Geographic Information Systems</a></li>
                        <li><a href="http://electronics.stackexchange.com/" title="electronics and electrical engineering professionals, students, and enthusiasts">Electrical Engineering</a></li>
                        <li><a href="http://android.stackexchange.com/" title="enthusiasts and power users of the Android operating system">Android Enthusiasts</a></li>
                        <li><a href="http://security.stackexchange.com/" title="IT security professionals">IT Security</a></li>
                            </ol></td><td><ol>
                        <li><a href="http://dba.stackexchange.com/" title="database professionals who wish to improve their database skills and learn from others in the community">Database Administrators</a></li>
                        <li><a href="http://drupal.stackexchange.com/" title="Drupal developers and administrators">Drupal Answers</a></li>
                        <li><a href="http://sharepoint.stackexchange.com/" title="SharePoint enthusiasts">SharePoint</a></li>
                        <li><a href="http://ux.stackexchange.com/" title="user experience researchers and experts">User Experience</a></li>
                        <li><a href="http://mathematica.stackexchange.com/" title="users of Mathematica">Mathematica</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#technology" class="more">
                                more (14)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://photo.stackexchange.com/" title="professional, enthusiast and amateur photographers">Photography</a></li>
                        <li><a href="http://scifi.stackexchange.com/" title="science fiction and fantasy enthusiasts">Science Fiction &amp; Fantasy</a></li>
                        <li><a href="http://cooking.stackexchange.com/" title="professional and amateur chefs">Seasoned Advice (cooking)</a></li>
                        <li><a href="http://diy.stackexchange.com/" title="contractors and serious DIYers">Home Improvement</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#lifearts" class="more">
                                more (13)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://english.stackexchange.com/" title="linguists, etymologists, and serious English language enthusiasts">English Language &amp; Usage</a></li>
                        <li><a href="http://skeptics.stackexchange.com/" title="scientific skepticism">Skeptics</a></li>
                        <li><a href="http://judaism.stackexchange.com/" title="those who base their lives on Jewish law and tradition and anyone interested in learning more">Mi Yodeya (Judaism)</a></li>
                        <li><a href="http://travel.stackexchange.com/" title="road warriors and seasoned travelers">Travel</a></li>
                        <li><a href="http://gaming.stackexchange.com/" title="passionate videogamers on all platforms">Arqade (gaming)</a></li>
                        <li><a href="http://bicycles.stackexchange.com/" title="people who build and repair bicycles, people who train cycling, or commute on bicycles">Bicycles</a></li>
                        <li><a href="http://rpg.stackexchange.com/" title="gamemasters and players of tabletop, paper-and-pencil role-playing games">Role-playing Games</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#culturerecreation" class="more">
                                more (22)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://math.stackexchange.com/" title="people studying math at any level and professionals in related fields">Mathematics</a></li>
                        <li><a href="http://stats.stackexchange.com/" title="statisticians, data analysts, data miners and data visualization experts">Cross Validated (stats)</a></li>
                        <li><a href="http://cstheory.stackexchange.com/" title="theoretical computer scientists and researchers in related fields">Theoretical Computer Science</a></li>
                        <li><a href="http://physics.stackexchange.com/" title="active researchers, academics and students of physics">Physics</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#science" class="more">
                                more (7)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://stackapps.com/" title="apps, scripts, and development with the Stack Exchange API">Stack Apps</a></li>
                        <li><a href="http://meta.stackoverflow.com/" title="meta-discussion of the Stack Exchange family of Q&amp;A websites">Meta Stack Overflow</a></li>
                        <li><a href="http://area51.stackexchange.com/" title="proposing new sites in the Stack Exchange network">Area 51</a></li>
                        <li><a href="http://careers.stackoverflow.com/">Stack Overflow Careers</a></li>
                    
                </ol>
            </td>
    </tr>
</tbody></table>
                </div>
            </div>

            <div id="copyright">
                site design / logo © 2013 stack exchange inc; 
                user contributions licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license">cc-wiki</a> 
                with <a href="http://blog.stackoverflow.com/2009/06/attribution-required/" rel="license">attribution required</a>
            </div>
            <div id="footer-flair">
                <a href="http://creativecommons.org/licenses/by-sa/3.0/" class="cc-wiki-link"></a>
            </div>
            <div id="svnrev">
                rev 2013.5.23.698
            </div>
            
        </div>
    </div>
    <noscript>
        <div id="noscript-warning">Stack Overflow works best with JavaScript enabled<img src="http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"></div>
    </noscript>
    <script type="text/javascript">var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-5620270-1']);
        _gaq.push(['_setCustomVar', 1, 'tags', '|java|image|file|']); 
        _gaq.push(['_setCustomVar', 2, 'accountid', '2724491',2]); 
_gaq.push(['_trackPageview']);
    var _qevents = _qevents || [];
    (function(){
        var s=document.getElementsByTagName('script')[0];
        var ga=document.createElement('script');
        ga.type='text/javascript';
        ga.async=true;
        ga.src='http://www.google-analytics.com/ga.js';
        s.parentNode.insertBefore(ga,s);
        var sc=document.createElement('script');
        sc.type='text/javascript';
        sc.async=true;
        sc.src='http://edge.quantserve.com/quant.js'; 
        s.parentNode.insertBefore(sc,s);
    })();
    </script>
    <script type="text/javascript">
        _qevents.push({ qacct: "p-c1rF4kxgLUzNc" });
    </script>        
    

</body></html>